Release 10.1A: OpenEdge Development:
ProDataSets
Using the REPOSITION Data-Relation
You can include the optional keyword
REPOSITIONon a Data-Relation definition that is part of a ProDataSet definition. As you will later see, there is also aREPOSITIONlogical attribute on a Data-Relation handle that lets you set this mode on or off at run time.The purpose of the reposition mode on a relation is to handle the situation where you want to load a limited set of child records into a ProDataSet table that is related to possibly multiple parent rows of another table in the ProDataSet. For example, you might want to include a separate State table with state abbreviation and full state name in your ProDataSet rather than joining that information into each individual
CustomerorOrderrecord in the ProDataSet. Or you might want to include anItemtable with all availableItemsin your ProDataSet and be able to join anItemto all of theOrderLinesthat include thatItem.If
REPOSITIONmode is true at the time of aFILL, either because the keyword is part of the definition or because you have set the attribute to true, then Progress ignores the Data-Relation that would otherwise filter the children to retrieve only those related to a parent of the relation, and fills the table as a top-level table.Example with REPOSITION not set
For example, consider an
OrderProDataSet with a Data-Relation fromttOrderLinetottItem, with relation fields ofttOrderline.ItemNumandttItem.ItemNum. If you do not define or set theREPOSITIONattribute, then Progress loads intottItemtheIteminformation for everyItemused in at least oneOrderLinethat is also loaded into the ProDataSet. There might well be multipleOrderLinesthat use the sameOrder, but because the default fill processing is to discard records with duplicate keys, Progress automatically discards all duplicates based on the unique index definition for thettItemtemp-table, and you wind up with exactly one instance of eachItemused on the ProDataSet’sOrderLines. If there is no unique index on thettItemtemp-table, then you wind up with one instance ofttItemfor eachOrderLinethat uses a givenItem, which is almost certainly not what you want.Example with REPOSITION set: loading
Alternatively, if you define or set the
REPOSITIONattribute of the relation, when Progress fills the ProDataSet, it disregards the relation fields of that Data-Relation and fills that table independent of its parent. This means that by default Progress loads all records from the child table’s database buffer into the temp-table. Or if you have prepared a specific query for the child table’s Data-Source, then the records that satisfy the query are loaded.Using the same example for
OrderLinesand theirItems, withREPOSITIONset to true, Progress loads allItemsintottItemregardless of whether they are used byOrderLinesin this instance of the ProDataSet. This makes the entire list ofItemsavailable for display and selection in the user interface, or within business logic that uses the ProDataSet. You can setREPOSITIONtrue or false for this type of relation, depending on your application requirements.Example with REPOSITION set: navigation
During navigation,
REPOSITIONmode serves a somewhat different purpose. As you learned in the introduction, Progress generates a dynamic query for each child table of a Data-Relation that you can use to browse the current records at that level, where the meaning of “current” is normally the set of children for the currently selected parent. IfREPOSITIONis true when your application is navigating the ProDataSet, then the query works differently. The query does not filter children, but selects all rows in the child table regardless of the parent. However, the child query is repositioned to the child row for the currently selected parent.Once again using the same example, if your user interface uses browse objects to show
OrderLinesof the currentOrderin one browse andItemsin another browse, then withREPOSITIONFalse, theItembrowse will show only the onettItemrow for the currentttOrderLine. WithREPOSITIONTrue, thettItembrowse displays allItemsand repositions to theItemfor the currentOrderLine. ThisREPOSITIONmode has no other effect when you are navigating the ProDataSet. Again, setREPOSITIONtoTrueorFalsefor this kind of many-to-one relationship, depending on which default behavior you want.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |